/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.persistencia;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author victorinox
 */
@Entity
@Table(name = "manutencao", catalog = "carlossa03", schema = "")
@NamedQueries({@NamedQuery(name = "Manutencao.findAll", query = "SELECT m FROM Manutencao m"), @NamedQuery(name = "Manutencao.findByManutencaoId", query = "SELECT m FROM Manutencao m WHERE m.manutencaoId = :manutencaoId"), @NamedQuery(name = "Manutencao.findByDataChamado", query = "SELECT m FROM Manutencao m WHERE m.dataChamado = :dataChamado"), @NamedQuery(name = "Manutencao.findByDataAtendimento", query = "SELECT m FROM Manutencao m WHERE m.dataAtendimento = :dataAtendimento"), @NamedQuery(name = "Manutencao.findByDataFechamento", query = "SELECT m FROM Manutencao m WHERE m.dataFechamento = :dataFechamento")})
public class Manutencao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "manutencao_id")
    private Integer manutencaoId;
    @Lob
    @Column(name = "observacao")
    private String observacao;
    @Basic(optional = false)
    @Column(name = "data_chamado")
    @Temporal(TemporalType.DATE)
    private Date dataChamado;
    @Basic(optional = false)
    @Column(name = "data_atendimento")
    @Temporal(TemporalType.DATE)
    private Date dataAtendimento;
    @Column(name = "data_fechamento")
    @Temporal(TemporalType.DATE)
    private Date dataFechamento;
    @ManyToMany(mappedBy = "manutencaoCollection", fetch = FetchType.LAZY)
    private List<Funcionario> funcionarioCollection;
    @JoinTable(name = "entrada_saida_manutencao", joinColumns = {@JoinColumn(name = "manutencao_id", referencedColumnName = "manutencao_id")}, inverseJoinColumns = {@JoinColumn(name = "entrada_saida_id", referencedColumnName = "entrada_saida_id")})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<EntradaSaida> entradaSaidaCollection;
    @JoinColumn(name = "cliente_id", referencedColumnName = "usuario_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Usuario clienteId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "manutencao", fetch = FetchType.LAZY)
    private List<ProdutoManutencao> produtoManutencaoCollection;
    @OneToMany(mappedBy = "manutencaoId")
    private List<OpercaoExtra> opercaoExtraCollection;

    public Manutencao() {
    }

    public Manutencao(Integer manutencaoId) {
        this.manutencaoId = manutencaoId;
    }

    public Manutencao(Integer manutencaoId, Date dataChamado, Date dataAtendimento) {
        this.manutencaoId = manutencaoId;
        this.dataChamado = dataChamado;
        this.dataAtendimento = dataAtendimento;
    }

    public Integer getManutencaoId() {
        return manutencaoId;
    }

    public void setManutencaoId(Integer manutencaoId) {
        this.manutencaoId = manutencaoId;
    }

    public String getObservacao() {
        return observacao;
    }

    public void setObservacao(String observacao) {
        this.observacao = observacao;
    }

    public Date getDataChamado() {
        return dataChamado;
    }

    public void setDataChamado(Date dataChamado) {
        this.dataChamado = dataChamado;
    }

    public Date getDataAtendimento() {
        return dataAtendimento;
    }

    public void setDataAtendimento(Date dataAtendimento) {
        this.dataAtendimento = dataAtendimento;
    }

    public Date getDataFechamento() {
        return dataFechamento;
    }

    public void setDataFechamento(Date dataFechamento) {
        this.dataFechamento = dataFechamento;
    }

    public List<Funcionario> getFuncionarioCollection() {
        return funcionarioCollection;
    }

    public void setFuncionarioCollection(List<Funcionario> funcionarioCollection) {
        this.funcionarioCollection = funcionarioCollection;
    }

    public List<EntradaSaida> getEntradaSaidaCollection() {
        return entradaSaidaCollection;
    }

    public void setEntradaSaidaCollection(List<EntradaSaida> entradaSaidaCollection) {
        this.entradaSaidaCollection = entradaSaidaCollection;
    }

    public Usuario getClienteId() {
        return clienteId;
    }

    public void setClienteId(Usuario clienteId) {
        this.clienteId = clienteId;
    }

    public List<ProdutoManutencao> getProdutoManutencaoCollection() {
        return produtoManutencaoCollection;
    }

    public void setProdutoManutencaoCollection(List<ProdutoManutencao> produtoManutencaoCollection) {
        this.produtoManutencaoCollection = produtoManutencaoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (manutencaoId != null ? manutencaoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Manutencao)) {
            return false;
        }
        Manutencao other = (Manutencao) object;
        if ((this.manutencaoId == null && other.manutencaoId != null) || (this.manutencaoId != null && !this.manutencaoId.equals(other.manutencaoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidade.persistencia.Manutencao[manutencaoId=" + manutencaoId + "]";
    }

    /**
     * @return the opercaoExtraCollection
     */
    public List<OpercaoExtra> getOpercaoExtraCollection() {
        return opercaoExtraCollection;
    }

    /**
     * @param opercaoExtraCollection the opercaoExtraCollection to set
     */
    public void setOpercaoExtraCollection(List<OpercaoExtra> opercaoExtraCollection) {
        this.opercaoExtraCollection = opercaoExtraCollection;
    }

}
